#! /user/bin/python3
# coding-utf-8
# @Time = 2024/11/4 17:35
# @Author:Poolaris
import yaml
from common.tools import sep, get_project_path


class GetConf:
    def __init__(self):
        with open(get_project_path() + sep(['config', 'environment.yaml'], add_sep_before=True),
                  "r", encoding="utf-8") as env_file:
            # print(env_file.read())
            self.env = yaml.load(env_file, Loader=yaml.FullLoader)

    def get_username_password(self, user):
        # return self.env['username'], self.env['password']
        return self.env["user"][user]['username'], self.env["user"][user]['password']

    def get_url(self):
        # return self.env["url_net"]
        return self.env["url_com"]

    def get_project_name(self):
        return self.env["project_name"]

    def get_mysql(self):
        return self.env["mysql"]

    def get_redis(self):
        return self.env["redis"]

    def get_qywx_webhook(self):
        return self.env["qywx_group"]["webhook"]

    def get_jenkins(self):
        return self.env["jenkins"]


if __name__ == '__main__':
    print(GetConf().get_username_password("william"))
    print(GetConf().get_url())
    print(GetConf().get_project_name())
    print(GetConf().get_mysql())
    print(GetConf().get_redis())
    print(GetConf().get_qywx_webhook())
    print("jenkins地址：", GetConf().get_jenkins()['url'])


